﻿
'shared functions for valid variable/function name check
Public Class loose_name_defination
    Protected Friend Shared Function _isMeaningfulMark(ByVal c As Char) As Boolean
        Return [false](c)
    End Function

    Private Shared Function valid_first(ByVal c As Char) As Boolean
        Return Not isspace(c) AndAlso Not isMeaningfulMark(c)
    End Function

    Private Shared Function valid_other(ByVal c As Char) As Boolean
        Return valid_first(c)
    End Function

    Public Shared Function parse(ByVal input As String, ByRef index As Int64, _
                                 ByRef output As String) As Boolean
        Return token(input, index, output, AddressOf valid_first, AddressOf valid_other)
    End Function
End Class

Public Class function_name_defination
    Inherits loose_name_defination
End Class

Public Class strong_name_defination
    Protected Friend Shared Function _isMeaningfulMark(ByVal c As Char) As Boolean
        Return [false](c)
    End Function

    Public Shared Function valid_first(ByVal c As Char) As Boolean
        Return language.english.isalpha(c) OrElse c = character.underline
    End Function

    Public Shared Function valid_other(ByVal c As Char) As Boolean
        Return language.english.isalpha(c) OrElse isdigit(c) OrElse c = character.underline OrElse c = character.dot
    End Function

    Public Shared Function parse(ByVal input As String, ByRef index As Int64, _
                                 ByRef output As String) As Boolean
        Return token(input, index, output, AddressOf valid_first, AddressOf valid_other)
    End Function
End Class

Public Class value_name_defination
    Inherits strong_name_defination
End Class

Public Class operator_name_defination
    Protected Friend Shared Function _isMeaningfulMark(ByVal c As Char) As Boolean
        Return [false](c)
    End Function

    Private Shared Function valid_first(ByVal c As Char) As Boolean
        Return Not isMeaningfulMark(c) AndAlso ismark(c) AndAlso _
               Not strong_name_defination.valid_first(c) AndAlso Not strong_name_defination.valid_other(c)
    End Function

    Private Shared Function valid_other(ByVal c As Char) As Boolean
        Return valid_first(c)
    End Function

    Public Shared Function parse(ByVal input As String, ByRef index As Int64, _
                                 ByRef output As String) As Boolean
        Return token(input, index, output, AddressOf valid_first, AddressOf valid_other)
    End Function
End Class
